﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public enum ContainerControlType
{
    DropDownList,
    ListBox
}

public enum ActionControlType
{
    Link,
    Button
}

public enum LayoutType
{
    Right,
    Bottom
}

public partial class _controls_MultiItemCollector : System.Web.UI.UserControl
{
    private ContainerControlType _sourceControltype;
    private ActionControlType _actionControlType;
    private HtmlTable _layoutGrid;
    private LayoutType _layoutType;

    private string _actionText;
    private ListControl _sourceList;

    public ContainerControlType SourceControlType
    {
        get
        {
            return _sourceControltype;
        }

        set
        {
            _sourceControltype = value;
        }
    }

    public ActionControlType ActionControlType
    {
        get
        {
            return _actionControlType;
        }

        set
        {
            this._actionControlType = value;
        }
    }

    public string ActionText
    {
        get
        {
            return this._actionText;
        }

        set
        {
            _actionText = value;
        }
    }

    
    protected void Page_Load(object sender, EventArgs e)
    {
           
    }

    private HtmlTable BuildLayoutGrid(LayoutType layout)
    {
        HtmlTable table = new HtmlTable();
                
        if (layout == LayoutType.Bottom)
        {
            // Build "Bottom" Layout

            for (int i = 0; i < 3; i++)
            {
                HtmlTableRow row = new HtmlTableRow();
                row.Cells.Add(new HtmlTableCell());
                table.Rows.Add(row);
            }
        }
        else
        {
            // Build "Right" Layout (Default)

            HtmlTableRow row = new HtmlTableRow();
            
            for(int i=0; i< 3; i++)
                row.Cells.Add(new HtmlTableCell());

            table.Rows.Add(row);
        }

        return table;
    }

    /// <summary>
    /// Gets the Source Container HtmlTableCell
    /// </summary>
    /// <returns>Source Container HtmlTableCell</returns>
    private HtmlTableCell GetSourceContainerCell()
    {
        if (_layoutGrid == null)
            BuildLayoutGrid(LayoutType.Right);

        return this._layoutGrid.Rows[0].Cells[0];
    }

    /// <summary>
    /// Gets the Destination Container HtmlTableCell
    /// </summary>
    /// <returns>Destination Container HtmlTableCell</returns>
    private HtmlTableCell GetDestinationContainerCell()
    {
        if (_layoutGrid == null)
            BuildLayoutGrid(LayoutType.Right);

        if (_layoutType == LayoutType.Bottom)
            return this._layoutGrid.Rows[2].Cells[0];

        return this._layoutGrid.Rows[0].Cells[2];
    }
    

}
